<template>
  <el-dialog class="save-img-dialog" :title="$t('保存图片')" :visible="centerDialogVisible" width="90%" center
    @before-close="$emit('close')" :show-close="false">
    <img :src="src" alt="" style="width: 100%;">
    <!-- <el-image :src="src" fit="fill"></el-image> -->
    <span slot="footer" class="dialog-footer">
      <el-button @click="$emit('close')">{{ $t('取消') }}</el-button>
      <el-button type="primary" @click="saveImage">{{ $t('保存图片') }}</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  data() {
    return {
    }
  },
  props: {
    centerDialogVisible: {
      type: Boolean,
      default() {
        return false
      },
    },
    src: {
      type: String,
      default: ""
    }
  },
  methods: {
    saveImage() {
      const link = document.createElement("a"); // 创建一个超链接对象实例
      link.download = "order" + this.orderId + ".png"; // 设置要下载的图片的名称
      link.href = this.href; // 将图片的URL设置到超链接的href中
      link.click(); // 触发超链接的点击事件
      this.$emit('close')
    },
  }
}
</script>